#ifndef MODULES_CORE_PINWRAP_H_
#define MODULES_CORE_PINWRAP_H_
#include "IBean.h"
//https://blog.csdn.net/wangpuqing1997/article/details/105201551
class PinWarp {
private:
	int pin;
public:
	PinWarp(int pin) :
					pin(pin) {
	}
	PinWarp(int pin, int mode, int initStatu) :
					pin(pin) {
		this->init(mode, initStatu);
	}
	PinWarp& operator =(int pin) {
		this->pin = pin;
		return *this;
	}
	void init(int mode, int initStatu) {
		pinMode(this->pin, mode);
		digitalWrite(this->pin, initStatu);
	}
	void higt() {
		digitalWrite(this->pin, HIGH);
	}
	void low() {
		digitalWrite(this->pin, LOW);
	}
	void write(int value) {
		digitalWrite(this->pin, value);
	}
	int read() {
		return digitalRead(this->pin);
	}
	long pulse() {
		return pulseIn(this->pin, HIGH);
	}
};

#endif /* MODULES_CORE_PINWRAP_H_ */
